﻿using System;
using System.Net;
using System.Runtime.Serialization;


namespace SMS.Entities
{
    [DataContract]
    public class SMSException
    {
        [DataMember]
        public string Message { get; set; }
        [DataMember]
        public SMSException InnerException;

        public SMSException(Exception ex)
        {
            while (ex.InnerException != null)
                ex = ex.InnerException;
            this.Message = ex.Message + ex.StackTrace;
        }
        public Exception ToException()
        {
            Exception e;
            SMSException ce = this;
            if (ce.InnerException != null)
            {
                Exception inner = ce.InnerException.ToException();
                e = new Exception(ce.Message, inner);
            }
            else
                e = new Exception(ce.Message);
            return e;
        }
    }
}
